<?php

class UserController extends Controller
{
	public function actionIndex()
	{
		$this->render('index');
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
        
        /**
        * Displays a particular model.
        * @param integer $id the ID of the model to be displayed
        */
        public function actionView($id) { //http://localhost/mstickers/index.php?r=user/view&id=1

            $model = $this->loadModel($id);
            
            $this->render('view', array(
                'name' => $model->name, 
            ));

//            $model = $this->loadModel($id);
//            $this->layout = '//layouts/user';
//            if (Yii::app()->user->id == $id) {
//
//                $friends = $this->getUserFriends($id);
//                $this->render('view', array(
//                    'model' => $model,
//                    'friends' => $friends,
//                ));
//            } else {
//                $this->layout = '//layouts/public-user';
//                $idUserLogin = Yii::app()->user->id;
//                $rolesUserLogin = $this->getRolesUserLogin($idUserLogin);
//
//                $this->render('publicView', array(
//                    'model' => $model,
//                    'rolesUserLogin' => $rolesUserLogin,
//                ));
//            }
        }
        
     /**
     * Returns the data model based on the primary key given in the GET variable.
     * If the data model is not found, an HTTP exception will be raised.
     * 
     * @param integer the ID of the model to be loaded
     */
    public function loadModel($id) {
        $model = User::model()->findByPk($id);
        if ($model === null)
            throw new CHttpException(404, 'The requested page does not exist.');
        return $model;
    }
}